package com.example.maggie.meizinote.di.module;

import com.example.maggie.meizinote.mvp.ui.adapter.HomeMenuAdapter;
import com.example.maggie.meizinote.mvp.ui.adapter.NoteListAdapter;
import com.jess.arms.di.scope.ActivityScope;

import dagger.Module;
import dagger.Provides;

import com.example.maggie.meizinote.mvp.contract.HomeContract;
import com.example.maggie.meizinote.mvp.model.HomeModel;


@Module
public class HomeModule {
    private HomeContract.View view;
    private NoteListAdapter adapter;
    private HomeMenuAdapter adapterClassify;

    /**
     * 构建HomeModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public HomeModule(HomeContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    HomeContract.View provideHomeView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    HomeContract.Model provideHomeModel(HomeModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    NoteListAdapter provideNoteListAdapter() {
        if (adapter == null) adapter = new NoteListAdapter();
        return adapter;
    }

    @ActivityScope
    @Provides
    HomeMenuAdapter provideHomeMenuAdapter() {
        if (adapterClassify == null) adapterClassify = new HomeMenuAdapter();
        return adapterClassify;
    }
}